/***************************************************************************
 *   Copyright (C) 2010 by programmeboy                                    *
 *   programmeboy@gmail.com                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.                                        *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
 ***************************************************************************/
 
#include "stdafx.h"
// #include <exdisp.h>
// #include <comdef.h>
// #include <atlconv.h>

#include "EagleEyesWnd.h"
//#include "Log.h"
#include "DriverLoader.h"

HANDLE m_hDriver;

//#define ENABLE_LOAD_DRIVER  1

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
    CPaintManagerUI::SetInstance(hInstance);
    CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("./skin"));

    HRESULT Hr = ::CoInitialize(NULL);
    if(FAILED(Hr)) 
        return 0;
    
#ifdef ENABLE_LOAD_DRIVER
    CDriverLoader::LoadDriver(&m_hDriver);
#endif

    CEagleEyesWnd* pFrame = new CEagleEyesWnd();
    if(pFrame == NULL) 
        return 0;
    
    pFrame->SetDriver(m_hDriver);
    pFrame->Create(NULL, _T("Eagle Eyes"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572);
    pFrame->CenterWindow();
    ::ShowWindow(*pFrame, SW_SHOW);

    CPaintManagerUI::MessageLoop();

#ifdef ENABLE_LOAD_DRIVER    
    CDriverLoader::UnloadDriver(m_hDriver);
#endif

    ::CoUninitialize();
    return 0;
}